<template>
  <div class="data-governance-view">
    <!-- 顶部概览卡片 -->
    <div class="overview-cards">
      <div class="overview-card">
        <div class="card-icon">
          <svg viewBox="0 0 24 24">
            <path d="M3,5H9V11H3V5M5,7V9H7V7H5M11,7H21V9H11V7M11,15H21V17H11V15M5,20L1.5,16.5L2.91,15.09L5,17.17L9.59,12.59L11,14L5,20Z" fill="currentColor"/>
          </svg>
        </div>
        <div class="card-content">
          <div class="card-title">数据完整性</div>
          <div class="card-value">{{ dataIntegrity }}%</div>
          <div class="card-change positive">↑ 2.3%</div>
        </div>
      </div>
      
      <div class="overview-card">
        <div class="card-icon">
          <svg viewBox="0 0 24 24">
            <path d="M19,3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3M19,5V19H5V5H19Z" fill="currentColor"/>
          </svg>
        </div>
        <div class="card-content">
          <div class="card-title">实时数据源</div>
          <div class="card-value">{{ activeSources }}</div>
          <div class="card-change neutral">─ 0%</div>
        </div>
      </div>
      
      <div class="overview-card">
        <div class="card-icon">
          <svg viewBox="0 0 24 24">
            <path d="M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M12,17A1.5,1.5 0 0,1 10.5,15.5A1.5,1.5 0 0,1 12,14A1.5,1.5 0 0,1 13.5,15.5A1.5,1.5 0 0,1 12,17M12,10.5A1.5,1.5 0 0,0 10.5,12L11,16H13L12.5,12A1.5,1.5 0 0,0 12,10.5Z" fill="currentColor"/>
          </svg>
        </div>
        <div class="card-content">
          <div class="card-title">异常事件</div>
          <div class="card-value">{{ anomalies }}</div>
          <div class="card-change negative">↑ 15%</div>
        </div>
      </div>
      
      <div class="overview-card">
        <div class="card-icon">
          <svg viewBox="0 0 24 24">
            <path d="M13,9H18.5L13,3.5V9M6,2H14L20,8V20A2,2 0 0,1 18,22H6C4.89,22 4,21.1 4,20V4C4,2.89 4.89,2 6,2M11,4H6V16L11,12L16,16V4H13V9H11V4Z" fill="currentColor"/>
          </svg>
        </div>
        <div class="card-content">
          <div class="card-title">治理报告</div>
          <div class="card-value">{{ reports }}</div>
          <div class="card-change positive">↑ 8%</div>
        </div>
      </div>
    </div>

    <!-- 主要内容区域 -->
    <div class="main-content">
      <!-- 左侧面板 -->
      <div class="left-panel">
        <!-- 数据质量监控 -->
        <div class="panel-section">
          <div class="section-header">
            <h3>数据质量监控</h3>
            <button class="refresh-btn" @click="refreshDataQuality">
              <svg viewBox="0 0 24 24">
                <path d="M17.65,6.35C16.2,4.9 14.21,4 12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20C15.73,20 18.84,17.45 19.73,14H17.65C16.83,16.33 14.61,18 12,18A6,6 0 0,1 6,12A6,6 0 0,1 12,6C13.66,6 15.14,6.69 16.22,7.78L13,11H20V4L17.65,6.35Z" fill="currentColor"/>
              </svg>
            </button>
          </div>
          
          <div class="quality-metrics">
            <div 
              v-for="metric in qualityMetrics" 
              :key="metric.id"
              class="metric-item"
            >
              <div class="metric-info">
                <div class="metric-name">{{ metric.name }}</div>
                <div class="metric-value" :class="metric.status">{{ metric.value }}%</div>
              </div>
              <div class="metric-progress">
                <div 
                  class="progress-bar" 
                  :class="metric.status"
                  :style="{ width: metric.value + '%' }"
                ></div>
              </div>
            </div>
          </div>
        </div>

        <!-- 实时预警 -->
        <div class="panel-section">
          <div class="section-header">
            <h3>实时预警</h3>
            <span class="alert-count">{{ alerts.length }}</span>
          </div>
          
          <div class="alerts-list">
            <div 
              v-for="alert in alerts" 
              :key="alert.id"
              class="alert-item"
              :class="alert.level"
            >
              <div class="alert-icon">
                <svg v-if="alert.level === 'critical'" viewBox="0 0 24 24">
                  <path d="M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M12,17A1.5,1.5 0 0,1 10.5,15.5A1.5,1.5 0 0,1 12,14A1.5,1.5 0 0,1 13.5,15.5A1.5,1.5 0 0,1 12,17M12,10.5A1.5,1.5 0 0,0 10.5,12L11,16H13L12.5,12A1.5,1.5 0 0,0 12,10.5Z" fill="currentColor"/>
                </svg>
                <svg v-else-if="alert.level === 'warning'" viewBox="0 0 24 24">
                  <path d="M12,2L13.09,8.26L22,9L17,14L18.18,23L12,19.77L5.82,23L7,14L2,9L10.91,8.26L12,2Z" fill="currentColor"/>
                </svg>
                <svg v-else viewBox="0 0 24 24">
                  <path d="M12,2A10,10 0 0,1 22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12A10,10 0 0,1 12,2M11,16.5L18,9.5L16.59,8.09L11,13.67L7.91,10.59L6.5,12L11,16.5Z" fill="currentColor"/>
                </svg>
              </div>
              <div class="alert-content">
                <div class="alert-title">{{ alert.title }}</div>
                <div class="alert-time">{{ formatTime(alert.time) }}</div>
              </div>
              <button class="alert-dismiss" @click="dismissAlert(alert.id)">
                <svg viewBox="0 0 24 24">
                  <path d="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z" fill="currentColor"/>
                </svg>
              </button>
            </div>
          </div>
        </div>
      </div>

      <!-- 右侧面板 -->
      <div class="right-panel">
        <!-- 数据流量分析 -->
        <div class="panel-section">
          <div class="section-header">
            <h3>数据流量分析</h3>
            <div class="chart-controls">
              <button 
                v-for="period in timePeriods" 
                :key="period"
                class="period-btn"
                :class="{ active: selectedPeriod === period }"
                @click="selectedPeriod = period"
              >
                {{ period }}
              </button>
            </div>
          </div>
          
          <div class="chart-container">
            <canvas ref="flowChart" class="flow-chart"></canvas>
          </div>
        </div>

        <!-- 系统健康度 -->
        <div class="panel-section">
          <div class="section-header">
            <h3>系统健康度</h3>
            <div class="health-score">{{ systemHealth }}%</div>
          </div>
          
          <div class="health-items">
            <div 
              v-for="system in systemComponents" 
              :key="system.id"
              class="health-item"
            >
              <div class="health-info">
                <div class="health-name">{{ system.name }}</div>
                <div class="health-status" :class="system.status">
                  {{ getStatusText(system.status) }}
                </div>
              </div>
              <div class="health-indicator">
                <div 
                  class="indicator-dot" 
                  :class="system.status"
                ></div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- 底部控制面板 -->
    <div class="control-panel">
      <div class="panel-tabs">
        <button 
          v-for="tab in controlTabs" 
          :key="tab.id"
          class="tab-btn"
          :class="{ active: activeControlTab === tab.id }"
          @click="activeControlTab = tab.id"
        >
          <svg viewBox="0 0 24 24">
            <path :d="tab.icon" fill="currentColor"/>
          </svg>
          {{ tab.name }}
        </button>
      </div>
      
      <div class="tab-content">
        <!-- 智能分析 -->
        <div v-if="activeControlTab === 'analysis'" class="analysis-panel">
          <div class="analysis-grid">
            <div class="analysis-card">
              <h4>游客流量预测</h4>
              <div class="prediction-chart">
                <canvas ref="predictionChart"></canvas>
              </div>
              <div class="prediction-summary">
                <span>预计明日峰值: </span>
                <strong>{{ predictedPeak }}人</strong>
              </div>
            </div>
            
            <div class="analysis-card">
              <h4>异常行为检测</h4>
              <div class="anomaly-list">
                <div 
                  v-for="anomaly in recentAnomalies" 
                  :key="anomaly.id"
                  class="anomaly-item"
                >
                  <div class="anomaly-icon">
                    <svg viewBox="0 0 24 24">
                      <path d="M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M12,17A1.5,1.5 0 0,1 10.5,15.5A1.5,1.5 0 0,1 12,14A1.5,1.5 0 0,1 13.5,15.5A1.5,1.5 0 0,1 12,17M12,10.5A1.5,1.5 0 0,0 10.5,12L11,16H13L12.5,12A1.5,1.5 0 0,0 12,10.5Z" fill="currentColor"/>
                    </svg>
                  </div>
                  <div class="anomaly-info">
                    <div class="anomaly-text">{{ anomaly.description }}</div>
                    <div class="anomaly-location">{{ anomaly.location }}</div>
                  </div>
                  <div class="anomaly-confidence">{{ anomaly.confidence }}%</div>
                </div>
              </div>
            </div>
          </div>
        </div>
        
        <!-- 数据治理 -->
        <div v-if="activeControlTab === 'governance'" class="governance-panel">
          <div class="governance-actions">
            <button class="governance-btn primary" @click="startDataCleanup">
              <svg viewBox="0 0 24 24">
                <path d="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z" fill="currentColor"/>
              </svg>
              数据清理
            </button>
            <button class="governance-btn" @click="validateDataIntegrity">
              <svg viewBox="0 0 24 24">
                <path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z" fill="currentColor"/>
              </svg>
              完整性验证
            </button>
            <button class="governance-btn" @click="generateReport">
              <svg viewBox="0 0 24 24">
                <path d="M13,9H18.5L13,3.5V9M6,2H14L20,8V20A2,2 0 0,1 18,22H6C4.89,22 4,21.1 4,20V4C4,2.89 4.89,2 6,2Z" fill="currentColor"/>
              </svg>
              生成报告
            </button>
          </div>
          
          <div class="governance-status">
            <div class="status-item">
              <div class="status-label">最后清理时间</div>
              <div class="status-value">{{ lastCleanupTime }}</div>
            </div>
            <div class="status-item">
              <div class="status-label">数据同步状态</div>
              <div class="status-value">{{ syncStatus }}</div>
            </div>
            <div class="status-item">
              <div class="status-label">备份状态</div>
              <div class="status-value">{{ backupStatus }}</div>
            </div>
          </div>
        </div>
        
        <!-- 配置管理 -->
        <div v-if="activeControlTab === 'config'" class="config-panel">
          <div class="config-sections">
            <div class="config-section">
              <h4>数据源配置</h4>
              <div class="config-list">
                <div 
                  v-for="source in dataSources" 
                  :key="source.id"
                  class="config-item"
                >
                  <div class="config-info">
                    <div class="config-name">{{ source.name }}</div>
                    <div class="config-url">{{ source.url }}</div>
                  </div>
                  <div class="config-actions">
                    <button class="config-btn" @click="editDataSource(source)">
                      <svg viewBox="0 0 24 24">
                        <path d="M20.71,7.04C21.1,6.65 21.1,6 20.71,5.63L18.37,3.29C18,2.9 17.35,2.9 16.96,3.29L15.12,5.12L18.87,8.87M3,17.25V21H6.75L17.81,9.93L14.06,6.18L3,17.25Z" fill="currentColor"/>
                      </svg>
                    </button>
                    <button class="config-btn danger" @click="removeDataSource(source.id)">
                      <svg viewBox="0 0 24 24">
                        <path d="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z" fill="currentColor"/>
                      </svg>
                    </button>
                  </div>
                </div>
              </div>
            </div>
            
            <div class="config-section">
              <h4>预警规则</h4>
              <div class="rule-list">
                <div 
                  v-for="rule in alertRules" 
                  :key="rule.id"
                  class="rule-item"
                >
                  <div class="rule-info">
                    <div class="rule-name">{{ rule.name }}</div>
                    <div class="rule-condition">{{ rule.condition }}</div>
                  </div>
                  <div class="rule-toggle">
                    <label class="toggle-switch">
                      <input 
                        type="checkbox" 
                        v-model="rule.enabled"
                        @change="updateRule(rule)"
                      />
                      <span class="toggle-slider"></span>
                    </label>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, computed, onMounted, nextTick } from 'vue'

// 响应式数据
const dataIntegrity = ref(96.8)
const activeSources = ref(12)
const anomalies = ref(3)
const reports = ref(24)
const selectedPeriod = ref('24h')
const activeControlTab = ref('analysis')
const systemHealth = ref(94)
const predictedPeak = ref(2580)
const lastCleanupTime = ref('2024-01-15 14:30')
const syncStatus = ref('正常')
const backupStatus = ref('已完成')

// 时间周期选项
const timePeriods = ref(['1h', '6h', '24h', '7d', '30d'])

// 数据质量指标
const qualityMetrics = ref([
  { id: 'completeness', name: '数据完整性', value: 98, status: 'excellent' },
  { id: 'accuracy', name: '数据准确性', value: 95, status: 'good' },
  { id: 'consistency', name: '数据一致性', value: 92, status: 'good' },
  { id: 'timeliness', name: '数据时效性', value: 88, status: 'warning' }
])

// 预警信息
const alerts = ref([
  {
    id: 'alert_001',
    title: '游客密度过高预警',
    level: 'critical',
    time: new Date(Date.now() - 300000)
  },
  {
    id: 'alert_002',
    title: '水质监测异常',
    level: 'warning',
    time: new Date(Date.now() - 600000)
  },
  {
    id: 'alert_003',
    title: '系统性能良好',
    level: 'info',
    time: new Date(Date.now() - 900000)
  }
])

// 系统组件
const systemComponents = ref([
  { id: 'database', name: '数据库服务', status: 'healthy' },
  { id: 'api', name: 'API网关', status: 'healthy' },
  { id: 'monitoring', name: '监控系统', status: 'warning' },
  { id: 'backup', name: '备份服务', status: 'healthy' },
  { id: 'analytics', name: '分析引擎', status: 'error' }
])

// 控制面板标签
const controlTabs = ref([
  {
    id: 'analysis',
    name: '智能分析',
    icon: 'M19,3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3M19,5V19H5V5H19Z'
  },
  {
    id: 'governance',
    name: '数据治理',
    icon: 'M12,2A10,10 0 0,1 22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12A10,10 0 0,1 12,2M11,16.5L18,9.5L16.59,8.09L11,13.67L7.91,10.59L6.5,12L11,16.5Z'
  },
  {
    id: 'config',
    name: '配置管理',
    icon: 'M12,15.5A3.5,3.5 0 0,1 8.5,12A3.5,3.5 0 0,1 12,8.5A3.5,3.5 0 0,1 15.5,12A3.5,3.5 0 0,1 12,15.5M19.43,12.97C19.47,12.65 19.5,12.33 19.5,12C19.5,11.67 19.47,11.34 19.43,11L21.54,9.37C21.73,9.22 21.78,8.95 21.66,8.73L19.66,5.27C19.54,5.05 19.27,4.96 19.05,5.05L16.56,6.05C16.04,5.65 15.5,5.32 14.87,5.07L14.5,2.42C14.46,2.18 14.25,2 14,2H10C9.75,2 9.54,2.18 9.5,2.42L9.13,5.07C8.5,5.32 7.96,5.66 7.44,6.05L4.95,5.05C4.73,4.96 4.46,5.05 4.34,5.27L2.34,8.73C2.22,8.95 2.27,9.22 2.46,9.37L4.57,11C4.53,11.34 4.5,11.67 4.5,12C4.5,12.33 4.53,12.65 4.57,12.97L2.46,14.63C2.27,14.78 2.22,15.05 2.34,15.27L4.34,18.73C4.46,18.95 4.73,19.03 4.95,18.95L7.44,17.94C7.96,18.34 8.5,18.68 9.13,18.93L9.5,21.58C9.54,21.82 9.75,22 10,22H14C14.25,22 14.46,21.82 14.5,21.58L14.87,18.93C15.5,18.68 16.04,18.34 16.56,17.94L19.05,18.95C19.27,19.03 19.54,18.95 19.66,18.73L21.66,15.27C21.78,15.05 21.73,14.78 21.54,14.63L19.43,12.97Z'
  }
])

// 异常行为数据
const recentAnomalies = ref([
  {
    id: 'anomaly_001',
    description: '游客聚集异常',
    location: '三圣岛观音像',
    confidence: 95
  },
  {
    id: 'anomaly_002',
    description: '噪音水平超标',
    location: '商业街区域',
    confidence: 82
  },
  {
    id: 'anomaly_003',
    description: '设备响应延迟',
    location: '监控中心',
    confidence: 78
  }
])

// 数据源配置
const dataSources = ref([
  {
    id: 'source_001',
    name: '监控摄像头数据',
    url: 'rtmp://monitor.scenic.com/live'
  },
  {
    id: 'source_002',
    name: '环境传感器数据',
    url: 'mqtt://sensors.scenic.com:1883'
  },
  {
    id: 'source_003',
    name: '游客统计数据',
    url: 'api://analytics.scenic.com/visitors'
  }
])

// 预警规则
const alertRules = ref([
  {
    id: 'rule_001',
    name: '游客密度预警',
    condition: '人数 > 1000/区域',
    enabled: true
  },
  {
    id: 'rule_002',
    name: '环境质量预警',
    condition: 'AQI > 150',
    enabled: true
  },
  {
    id: 'rule_003',
    name: '设备故障预警',
    condition: '响应时间 > 5秒',
    enabled: false
  }
])

// 方法
const refreshDataQuality = () => {
  console.log('刷新数据质量指标')
  // 模拟数据更新
  qualityMetrics.value.forEach(metric => {
    metric.value = Math.max(80, Math.min(100, metric.value + (Math.random() - 0.5) * 4))
  })
}

const dismissAlert = (alertId) => {
  const index = alerts.value.findIndex(alert => alert.id === alertId)
  if (index > -1) {
    alerts.value.splice(index, 1)
  }
}

const getStatusText = (status) => {
  const statusMap = {
    'healthy': '正常',
    'warning': '警告',
    'error': '异常'
  }
  return statusMap[status] || status
}

const formatTime = (date) => {
  return date.toLocaleTimeString('zh-CN', {
    hour: '2-digit',
    minute: '2-digit'
  })
}

const startDataCleanup = () => {
  console.log('开始数据清理')
  lastCleanupTime.value = new Date().toLocaleString('zh-CN')
}

const validateDataIntegrity = () => {
  console.log('验证数据完整性')
  dataIntegrity.value = Math.min(100, dataIntegrity.value + 0.5)
}

const generateReport = () => {
  console.log('生成治理报告')
  reports.value++
}

const editDataSource = (source) => {
  console.log('编辑数据源:', source.name)
}

const removeDataSource = (sourceId) => {
  const index = dataSources.value.findIndex(source => source.id === sourceId)
  if (index > -1) {
    dataSources.value.splice(index, 1)
  }
}

const updateRule = (rule) => {
  console.log('更新规则:', rule.name, '启用状态:', rule.enabled)
}

// 初始化图表
const initCharts = () => {
  nextTick(() => {
    // 这里可以集成 Chart.js 或其他图表库
    console.log('初始化图表')
  })
}

// 生命周期
onMounted(() => {
  initCharts()
})
</script>

<style scoped>
/* CSS变量定义 */
:root {
  --primary-green: #00ff88;
  --secondary-green: #00d4aa;
  --accent-green: #4caf50;
  --dark-green: #1b5e20;
  --light-green: #e8f5e8;
  --water-blue: #00bcd4;
  --nature-gold: #ffab40;
  --bg-primary: rgba(13, 27, 42, 0.95);
  --bg-secondary: rgba(0, 50, 30, 0.85);
  --glass-bg: rgba(0, 255, 136, 0.08);
  --border-color: rgba(0, 255, 136, 0.3);
}

.data-governance-view {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, 
    rgba(13, 27, 42, 0.95) 0%, 
    rgba(0, 50, 30, 0.85) 50%, 
    rgba(13, 27, 42, 0.95) 100%),
    url('@/assets/images/jingqu.jpg') center center / cover no-repeat;
  color: #ffffff;
  font-family: 'Microsoft YaHei', sans-serif;
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 16px;
  z-index: 2;
  overflow: hidden;
}

.data-governance-view::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(ellipse at center, 
    rgba(0, 255, 136, 0.1) 0%, 
    rgba(0, 50, 30, 0.3) 50%, 
    rgba(13, 27, 42, 0.4) 100%);
  z-index: 0;
  pointer-events: none;
}

/* 顶部概览卡片 */
.overview-cards {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.overview-card {
  background: var(--glass-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(10px);
}

.overview-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary-green), var(--secondary-green));
}

.overview-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 30px rgba(0, 255, 136, 0.2);
  background: rgba(0, 255, 136, 0.12);
}

.card-icon {
  width: 48px;
  height: 48px;
  background: rgba(0, 255, 136, 0.2);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-green);
}

.card-icon svg {
  width: 24px;
  height: 24px;
}

.card-content {
  flex: 1;
}

.card-title {
  font-size: 14px;
  color: #7a8699;
  margin-bottom: 8px;
}

.card-value {
  font-size: 24px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 4px;
}

.card-change {
  font-size: 12px;
  font-weight: 500;
}

.card-change.positive {
  color: #00ff88;
}

.card-change.negative {
  color: #ff4757;
}

.card-change.neutral {
  color: #7a8699;
}

/* 主要内容区域 */
.main-content {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 16px;
  flex: 1;
  min-height: 0;
}

.left-panel,
.right-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-section {
  background: var(--glass-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  overflow: hidden;
  backdrop-filter: blur(10px);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: rgba(0, 255, 136, 0.12);
  border-bottom: 1px solid var(--border-color);
}

.section-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--primary-green);
  text-shadow: 0 0 15px var(--primary-green);
}

.refresh-btn {
  width: 32px;
  height: 32px;
  background: var(--glass-bg);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: #7a8699;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(5px);
}

.refresh-btn:hover {
  background: var(--primary-green);
  color: #0f1419;
  transform: rotate(180deg);
  box-shadow: 0 5px 15px rgba(0, 255, 136, 0.3);
}

.refresh-btn svg {
  width: 16px;
  height: 16px;
}

.alert-count {
  background: #ff4757;
  color: #ffffff;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.health-score {
  font-size: 20px;
  font-weight: 700;
  color: #00ff88;
}

/* 数据质量监控 */
.quality-metrics {
  padding: 20px;
}

.metric-item {
  margin-bottom: 20px;
  padding: 12px;
  background: var(--glass-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  backdrop-filter: blur(5px);
}

.metric-item:last-child {
  margin-bottom: 0;
}

.metric-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.metric-name {
  font-size: 14px;
  color: #ffffff;
}

.metric-value {
  font-size: 16px;
  font-weight: 600;
}

.metric-value.excellent {
  color: #00ff88;
}

.metric-value.good {
  color: #00d4aa;
}

.metric-value.warning {
  color: #ffa500;
}

.metric-value.error {
  color: #ff4757;
}

.metric-progress {
  height: 6px;
  background: #2a3441;
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

.progress-bar.excellent {
  background: linear-gradient(90deg, #00ff88, #00d4aa);
}

.progress-bar.good {
  background: linear-gradient(90deg, #00d4aa, #00b896);
}

.progress-bar.warning {
  background: linear-gradient(90deg, #ffa500, #ff9800);
}

.progress-bar.error {
  background: linear-gradient(90deg, #ff4757, #ff3742);
}

/* 实时预警 */
.alerts-list {
  padding: 16px;
  max-height: 300px;
  overflow-y: auto;
}

.alerts-list::-webkit-scrollbar {
  width: 6px;
}

.alerts-list::-webkit-scrollbar-track {
  background: #1a1f2e;
}

.alerts-list::-webkit-scrollbar-thumb {
  background: #3d4751;
  border-radius: 3px;
}

.alert-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  margin-bottom: 8px;
  background: #2a3441;
  border-radius: 6px;
  border-left: 4px solid;
  transition: all 0.3s ease;
}

.alert-item.critical {
  border-left-color: #ff4757;
  background: rgba(255, 71, 87, 0.1);
}

.alert-item.warning {
  border-left-color: #ffa500;
  background: rgba(255, 165, 0, 0.1);
}

.alert-item.info {
  border-left-color: #00ff88;
  background: rgba(0, 255, 136, 0.1);
}

.alert-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.alert-item.critical .alert-icon {
  color: #ff4757;
}

.alert-item.warning .alert-icon {
  color: #ffa500;
}

.alert-item.info .alert-icon {
  color: #00ff88;
}

.alert-icon svg {
  width: 16px;
  height: 16px;
}

.alert-content {
  flex: 1;
}

.alert-title {
  font-size: 14px;
  color: #ffffff;
  margin-bottom: 2px;
}

.alert-time {
  font-size: 12px;
  color: #7a8699;
}

.alert-dismiss {
  width: 24px;
  height: 24px;
  background: none;
  border: none;
  color: #7a8699;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.alert-dismiss:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.alert-dismiss svg {
  width: 14px;
  height: 14px;
}

/* 图表控制 */
.chart-controls {
  display: flex;
  gap: 4px;
}

.period-btn {
  padding: 6px 12px;
  background: #2a3441;
  border: 1px solid #3d4751;
  border-radius: 4px;
  color: #7a8699;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.3s ease;
}

.period-btn:hover {
  background: #3d4751;
  color: #ffffff;
}

.period-btn.active {
  background: #00ff88;
  color: #0f1419;
  border-color: #00ff88;
}

.chart-container {
  padding: 20px;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.2);
}

.flow-chart {
  max-width: 100%;
  max-height: 100%;
}

/* 系统健康度 */
.health-items {
  padding: 16px;
}

.health-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  margin-bottom: 8px;
  background: var(--glass-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  transition: all 0.3s ease;
  backdrop-filter: blur(5px);
}

.health-item:hover {
  background: rgba(0, 255, 136, 0.12);
  transform: translateX(3px);
}

.health-name {
  font-size: 14px;
  color: #ffffff;
  margin-bottom: 2px;
}

.health-status {
  font-size: 12px;
}

.health-status.healthy {
  color: #00ff88;
}

.health-status.warning {
  color: #ffa500;
}

.health-status.error {
  color: #ff4757;
}

.health-indicator {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.indicator-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  box-shadow: 0 0 8px currentColor;
}

.indicator-dot.healthy {
  background: #00ff88;
  color: #00ff88;
}

.indicator-dot.warning {
  background: #ffa500;
  color: #ffa500;
}

.indicator-dot.error {
  background: #ff4757;
  color: #ff4757;
}

/* 底部控制面板 */
.control-panel {
  position: relative;
  z-index: 1;
  background: rgba(26, 31, 46, 0.9);
  border: 1px solid #2a3441;
  border-radius: 8px;
  overflow: hidden;
  backdrop-filter: blur(10px);
}

.panel-tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid #2a3441;
}

.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  background: none;
  border: none;
  color: #7a8699;
  cursor: pointer;
  transition: all 0.3s ease;
  border-bottom: 3px solid transparent;
}

.tab-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #ffffff;
}

.tab-btn.active {
  color: #00ff88;
  border-bottom-color: #00ff88;
}

.tab-btn svg {
  width: 16px;
  height: 16px;
}

.tab-content {
  padding: 20px;
}

/* 智能分析面板 */
.analysis-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.analysis-card {
  background: var(--glass-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  backdrop-filter: blur(10px);
}

.analysis-card h4 {
  margin: 0 0 16px 0;
  font-size: 16px;
  color: var(--primary-green);
  text-shadow: 0 0 10px var(--primary-green);
}

.prediction-chart {
  height: 120px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #7a8699;
}

.prediction-summary {
  font-size: 14px;
  color: #7a8699;
}

.prediction-summary strong {
  color: #00ff88;
}

.anomaly-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.anomaly-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

.anomaly-icon {
  width: 20px;
  height: 20px;
  color: #ff4757;
}

.anomaly-icon svg {
  width: 16px;
  height: 16px;
}

.anomaly-info {
  flex: 1;
}

.anomaly-text {
  font-size: 13px;
  color: #ffffff;
  margin-bottom: 2px;
}

.anomaly-location {
  font-size: 11px;
  color: #7a8699;
}

.anomaly-confidence {
  font-size: 12px;
  color: #00ff88;
  font-weight: 500;
}

/* 数据治理面板 */
.governance-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

.governance-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--glass-bg);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: #ffffff;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.3s ease;
  backdrop-filter: blur(5px);
}

.governance-btn:hover {
  background: rgba(0, 255, 136, 0.15);
  transform: translateY(-1px);
}

.governance-btn.primary {
  background: var(--primary-green);
  color: #0f1419;
  border-color: var(--primary-green);
}

.governance-btn.primary:hover {
  background: var(--secondary-green);
}

.governance-btn svg {
  width: 16px;
  height: 16px;
}

.governance-status {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.status-item {
  background: #2a3441;
  border: 1px solid #3d4751;
  border-radius: 6px;
  padding: 16px;
  text-align: center;
}

.status-label {
  font-size: 12px;
  color: #7a8699;
  margin-bottom: 8px;
}

.status-value {
  font-size: 16px;
  font-weight: 600;
  color: #00ff88;
}

/* 配置管理面板 */
.config-sections {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.config-section h4 {
  margin: 0 0 16px 0;
  font-size: 16px;
  color: #00ff88;
}

.config-list,
.rule-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.config-item,
.rule-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: var(--glass-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  backdrop-filter: blur(5px);
  margin-bottom: 8px;
}

.config-item:hover,
.rule-item:hover {
  background: rgba(0, 255, 136, 0.12);
  transform: translateX(2px);
}

.config-name,
.rule-name {
  font-size: 14px;
  color: #ffffff;
  margin-bottom: 2px;
}

.config-url,
.rule-condition {
  font-size: 12px;
  color: #7a8699;
}

.config-actions {
  display: flex;
  gap: 4px;
}

.config-btn {
  width: 28px;
  height: 28px;
  background: #3d4751;
  border: none;
  border-radius: 4px;
  color: #7a8699;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.config-btn:hover {
  background: #4a5563;
  color: #ffffff;
}

.config-btn.danger:hover {
  background: #ff4757;
  color: #ffffff;
}

.config-btn svg {
  width: 14px;
  height: 14px;
}

/* 切换开关 */
.rule-toggle {
  margin-left: 12px;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #3d4751;
  border-radius: 12px;
  transition: 0.3s;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: #ffffff;
  border-radius: 50%;
  transition: 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
  background: #00ff88;
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(20px);
}

/* 响应式设计 */
@media (max-width: 1400px) {
  .overview-cards {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .analysis-grid {
    grid-template-columns: 1fr;
  }
  
  .config-sections {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .data-governance-view {
    padding: 12px;
  }
  
  .overview-cards {
    grid-template-columns: 1fr;
  }
  
  .main-content {
    flex-direction: column;
  }
  
  .governance-actions {
    flex-direction: column;
  }
  
  .governance-status {
    grid-template-columns: 1fr;
  }
}
</style> 